package com.muki.extractor;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;

import com.mongodb.WriteResult;
import com.muki.contentSeen.Content;
import com.muki.repository.ContentRepository;

/**
 * 信息抓取器
 * @author ljh_2017
 *
 */
@Service
public class ExtractorService {

	@Autowired private ContentRepository contentRepository;
	
	@Autowired private MongoTemplate mongoTemplate;
	
	public List<Content> getUnExtractContents() {
		return contentRepository.findUnExtractContentLimit();
	}
	
	public WriteResult updateContent(Content content) {
		return mongoTemplate.updateFirst(new Query(Criteria.where("url").is(content.getUrl())), new Update().set("status", true), "mongo_content");
	}
}
